package com.liujianlei.redis7_study.redistest;
import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.RedisCommands;

import java.util.List;

/**
 * @author tongchen
 * @create 2023-07-04 10:03
 */
public class Demo01 {
    public static void main(String[] args) {
        //使用构建器创建链接内容
      RedisURI redisURI=  RedisURI.builder().redis("120.27.237.218").withPort(6379)
                .withAuthentication("default","111111").build();
        //创建连接客户端
        RedisClient redisClient = RedisClient.create(redisURI);
        StatefulRedisConnection<String, String> connect = redisClient.connect();
        //操作命令API
        RedisCommands<String, String> commands = connect.sync();
        //执行命令
        List<String> keys = commands.keys("*");
        System.out.println(keys);
    }
}
